const validatePhone = (rule, value, callback) => {
  if (!/^[1]([3-9])[0-9]{9}$/.test(value)) {
    callback(new Error('请输入正确的手机号格式'))
  } else {
    callback()
  }
}
const validateEmail = (rule, value, callback) => {
  if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value)) {
    callback(new Error('请输入正确的邮件格式'))
  } else {
    callback()
  }
}

export const option = function () {
  return {
    refreshBtn: true,
    columnBtn: true,
    border: true,
    stripe: true,
    index: true,
    editBtn: true,
    delBtn: true,
    align: 'center',
    addBtn: true,
    menu: true,
    indexLabel: '序号',
    column: [
      {
        label: '姓名',
        prop: 'contactNameA',
        rules: [
          {
            required: true,
            message: '请输入姓名',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '性别',
        prop: 'sexA',
        type: 'radio',
        dicData: [
          {
            label: '男',
            value: '男'
          },
          {
            label: '女',
            value: '女'
          }
        ],
        rules: [
          {
            required: true,
            message: '请选择性别',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '部门',
        prop: 'deptA',
        rules: [
          {
            required: true,
            message: '请输入部门',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '职务',
        prop: 'postA',
        rules: [
          {
            required: true,
            message: '请输入职务',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '手机号码',
        prop: 'phoneA',
        rules: [
          {
            required: true,
            message: '请输入手机号码',
            trigger: 'blur'
          },
          { validator: validatePhone, trigger: 'blur' }
        ]
      },
      {
        label: '邮箱',
        prop: 'emailA',
        rules: [
          {
            required: true,
            message: '请输入邮箱',
            trigger: 'blur'
          },
          { validator: validateEmail, trigger: 'blur' }
        ]
      },

      {
        label: '固定电话',
        prop: 'telephoneA'
      }
    ]
  }
}
